package classes.multithread;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author : DuJiabao
 * @Date : 2021/2/9 10:13
 * @Project : java_learning
 * @File : null.java
 * @Desc :
 */
public class CallableTest2 {
  public static void main(String[] args) {
    ExecutorService exec = Executors.newCachedThreadPool();
    List<Future<String>> res = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
      Future<String> submit = exec.submit(new CallableImpl());
      res.add(submit);
    }

    try {
      for (Future<String> re : res) {
        System.out.println(re.get());
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      exec.shutdown();
    }
  }
}
